<template>
  <div class="">
    <el-table border height="400" v-loading="loading" :data="dataList">
      <el-table-column
        prop="specialEnergyConsumptionType"
        label="用能类型"
        align="center"
        min-width="200"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="name"
        label="设备名称"
        align="center"
        min-width="200"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="installLocation"
        label="设备安装位置"
        align="center"
        min-width="200"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="type"
        label="设备类型"
        align="center"
        min-width="200"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="roomName"
        label="房间名称"
        align="center"
        min-width="200"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        align="center"
        min-width="120"
        prop="status"
        label="设备状态"
      >
        <!-- <template slot-scope="scope">
          {{ scope.row.status == 2 ? "故障" : "启用" }}
        </template> -->
      </el-table-column>
<!--      <el-table-column-->
<!--        prop="electricValue"-->
<!--        label="累计电耗（kwh）"-->
<!--        align="center"-->
<!--        min-width="200"-->
<!--        show-overflow-tooltip-->
<!--      >-->
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.electricValue | numDealfilters }}-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>
  </div>
</template>

    <script>
import { getDevice } from "@/api/general/index.js";
import { dealElectricity } from "@/utils";
export default {
  filters: {
    numDealfilters(num) {
      if (null != num) {
        return dealElectricity(num, 1, 2);
      } else {
        return "";
      }
    },
  },
  components: {},
  props: {
    year: {
      type: [String, Number],
      default: 2024,
    },
  },
  data() {
    return {
      dataList: [],
      loading: false,
    };
  },
  created() {},
  mounted() {},
  watch: {
    year: {
      handler(val) {
        if (val) {
          this.requestYearlist();
        }
      },
      deep: false,
      immediate: true,
    },
  },
  methods: {
    // 年度统计
    requestYearlist() {
      this.loading = true;
      let query = {
        year: this.year,
        pageSize: 999999999,
      };
      query.deptIds = [this.$store.state.user.deptId];
      getDevice(query)
        .then((res) => {
          this.loading = false;
          if (res.code === 700) {
            this.$message.warning(res.msg);
            return false;
          }
          // console.log(res, "tabledata");
          this.dataList = res?.rows ?? [];
        })
        .catch(() => {
          // this.$message.error("系统错误,请联系管理员!");
        });
    },
  },
};
</script>

    <style lang="scss" scoped></style>
